<?php
Zend::loadClass('Led_Entity_Renderer');
Zend::loadClass('Led_Entity_Collection');

class PageController extends Zend_Controller_Action 
{
        
    
    public function indexAction()
    {
        $app = Led_Application::getInstance();

        $finder = $app->getEdo()->getFinder('ent_language');
        
        $obj = $finder->findFirst(array(array('langdefault', '=', 1)));
        
        print_r($obj);
    }
    
    
    public function viewAction()
    {
        $app = Led_Application::getInstance();
        
        $page = $app->getEdo()->fetch($this->_getParam('id'), 'ent_navigationmenu');
        
        $app->setLangid($page->lang_id);
        $app->setPage($page);
        
        $lang = $app->getEdo()->fetch($page->lang_id, 'ent_language');
        
        $template = $app->getEdo()->fetch($page->template, 'ent_codetemplate');

        $mode = 'pretail';
                
        $body = Led_Entity_Renderer::getInstance()->render($template, $mode);        
                        
        Zend::loadClass('Lead_Document');

        $ini = parse_ini_file($app->getSafeRoot() . '/' . $lang->headfile, true);
               
        
        $document = $app->getDocument();
        $document->setContentType('iso-8859-1');
        
        
        foreach($ini['style'] as $style)
            $document->head->style->add('/' . $style);
        
        $document->head->setTitle($lang->appname);            
        $document->head->meta->add('generator', 'LED 2.0 beta');
               
        $document->body->append($body);
        
        $this->getResponse()->appendBody($document->render());

        
               
        
    }
    
}